/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package others.bean;

import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import login.bean.LoginBean;
import login.business.LoginBusiness;
import others.business.TerminalBusiness;

/**
 *
 * @author Javier
 */
@ManagedBean
@RequestScoped
public class TerminalBean implements Serializable{
    
    public String user;
    private LoginBean lb ;
    
    public TerminalBean() {
        lb = (LoginBean) FacesContext.getCurrentInstance()
                .getExternalContext().getSessionMap().get("loginBean");
        user = lb.getUser();
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }
     
    public String execute(String sql){
        return new TerminalBusiness().doStatement(sql);
    }
    
    public String handleCommand(String command, String[] params) {
        String sql = command;
        for (String param : params) {
            sql = sql.concat(" "+param);
        }
        return execute(sql);
    }
}
